package cn.happyjava.springbootsecurity.controller;

import cn.happyjava.springbootsecurity.pojo.User;
import cn.happyjava.springbootsecurity.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TestController {

    @Autowired
    private UserService userService;

    @PreAuthorize("hasAuthority('USER')")
    @GetMapping(value = "/user/getUsers")
    public Object getUsers() {
        List<User> users = userService.findAll();
        return users;
    }

}
